# Contributor: Olliver Schinagl <oliver@schinagl.nl>
# Maintainer: Olliver Schinagl <oliver@schinagl.nl>
pkgname=openv2g
pkgver=0.9.5
pkgrel=0
pkgdesc="Implements ISO IEC 15118 and also the DIN 70121 vehicle to grid (V2G) communication interface"
url="https://openv2g.sourceforge.net/"
arch="all"
license="LGPL-3.0-or-later"
options="!check" # No tests available
subpackages="lib$pkgname:libs lib$pkgname-dev"
source="
	0001-Enable-XMLDSIG-codec-support.patch
	0002-Violate-the-spec-less-by-downgrading-to-ASCII-for-UT.patch
	makefiles.patch
	$pkgname.pc.in
	$pkgname-$pkgver.zip::https://downloads.sourceforge.net/sourceforge/openv2g/OpenV2G_$pkgver.zip
"

unpack() {
	mkdir -p "$builddir"
	unzip "$srcdir/$pkgname-$pkgver.zip" -d "$builddir"
	# To ensure patches can be applied, convert the \r\n code-base first.
	find "$builddir" -type f -exec dos2unix '{}' \;
}

build() {
	cd Release
	make

	sed \
	    -e "s|@PKGVER@|${pkgver}|g" \
	    "$srcdir/$pkgname.pc.in" > "$builddir/$pkgname.pc"

}

package() {
	depends="lib$pkgname"
	cd Release
	make DESTDIR="$pkgdir/usr" install

	install -D -m 0644 -t "$pkgdir/usr/lib/pkgconfig/" \
	        "$builddir/$pkgname.pc"
}

sha512sums="
0d055188801e0724b78f935bd3de72ad7b673dab894577f255eb895a4871f1e775476adf6c55427c293e85f488140cad51d7ce85a626dbba6bb87c96a3866064  0001-Enable-XMLDSIG-codec-support.patch
6737110c91830f9d93fbce1cc54a73d0a86d12ddefb69cbe1a91ffdb478626b0aa8d0ccdc3392fd2213747a5eef5da948a0249e9e3c8844953d36118dc28425c  0002-Violate-the-spec-less-by-downgrading-to-ASCII-for-UT.patch
7f23f23eba706e1d1e8dd3085c082dfbe3a50387b8d895a4bf321077bf27b7b0c4b72669e7e5db2be0eb16687deeec9832f0804fb96485c430bc00e83f9f45b5  makefiles.patch
94d1f15c33ae7327d76320d5ba35febd6068393e70667729953edfc3a54eb1dc91513bec8abf11b14b53154594746123cca8db00cb31d5a5d139b38054d8a986  openv2g.pc.in
a492012fc1820d97fe679f997404d8ed02cfee85137197dbd8084daf35b078c29b54e87c446dec3a420e6b414a6c40cd8eca0528038ab986c4fc91240d809a02  openv2g-0.9.5.zip
"
